package com.fho4565.commands;

import com.fho4565.main.Utils;
import com.mojang.brigadier.CommandDispatcher;
import net.minecraft.commands.CommandSourceStack;
import net.minecraft.commands.Commands;
import net.minecraft.commands.arguments.EntityArgument;


public class DisMount {
    public static void register(CommandDispatcher<CommandSourceStack> dispatcher) {
        dispatcher.register(
                Commands.literal("dismount").requires(s -> s.hasPermission(2))
                        .then(Commands.argument("entity", EntityArgument.entity()).executes(context -> {
                            if (!EntityArgument.getEntity(context, "entity").getPassengers().isEmpty()) {
                                EntityArgument.getEntity(context, "entity").unRide();
                                Utils.sendTCdFeedback(context, "mcd.com.fho4565.command.dismount.success");
                                return 1;
                            } else {
                                Utils.sendTCdFeedback(context, "mcd.com.fho4565.command.dismount.failed", true);
                                return 0;
                            }
                        }))

        );
    }
}
